package GUI;

import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


import javax.swing.JComboBox;
import javax.swing.JLabel;
public class StudentMainWin extends JFrame {

	private JPanel FirstPanel = null;
	private JButton StudentsButton = null;
	private StudentForm sf;
	
	public StudentMainWin() { // Constructor of the main student frame..
		super();
		initialize();
	}
	
	private void initialize() {
		this.setSize(300, 200);
		this.setContentPane(getFirstPanel());
		this.setTitle("Academic Managment Tool");
		this.sf=new StudentForm();
		
		sf.btnClose.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				setContentPane(getFirstPanel());
			}
		});
	}
	
	
	private JPanel getFirstPanel() {
		if (FirstPanel == null) {
			FirstPanel = new JPanel();
			FirstPanel.setLayout(null);
			FirstPanel.add(getStudentsButton(), null);
			
			JComboBox comboBox = new JComboBox();
			comboBox.setBounds(179, 79, 95, 22);
			FirstPanel.add(comboBox);
			
			JLabel lblNewLabel = new JLabel("Choose Student");
			lblNewLabel.setBounds(45, 83, 124, 14);
			FirstPanel.add(lblNewLabel);
		}
		return FirstPanel; 
	}
	
	private JButton getStudentsButton() {
		if (StudentsButton == null) {
			StudentsButton = new JButton();
			StudentsButton.setBounds(new Rectangle(45, 43, 229, 29));
			StudentsButton.setText("Student info");
			StudentsButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("actionPerformed()"); 
					setContentPane(sf);
				}
			});
		}
		return StudentsButton;
	}
}
